//
//  MineViewController.m
//  13-Homework
//
//  Created by dllo on 16/8/2.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "MineViewController.h"
#import "UserTableViewCell.h"
#import "ArticleTableViewCell.h"
#import "SettingsTableViewCell.h"
#define kTableViewReuse @"mineReuse"
#define kArticleTableViewReuse @"wenzhangReuse"
#define kSettingsTableViewReuse @"settingReuse"
@interface MineViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) NSArray *articleNameArray;
@property (nonatomic, strong) NSArray *settingsArray;
@end

@implementation MineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.articleNameArray = @[@"公开文章", @"私密文章", @"我的收藏", @"喜欢的文章", @"我的钱包"];
    self.settingsArray = @[@"夜间模式", @"浏览记录", @"通用设置", @"分享简书", @"意见反馈", @"觉得不错 给个好评"];
    _tableView.tableFooterView = [[UIView alloc] init];
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 10;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 0) {
        return 1;
    } else if (section == 1) {
        return _articleNameArray.count;
    } else {
        return _settingsArray.count;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        UserTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kTableViewReuse];
        return cell;
    } else if (indexPath.section == 1) {
        ArticleTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kArticleTableViewReuse];
        cell.articleLabel.text = _articleNameArray[indexPath.row];
        return cell;
    } else {
        SettingsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kSettingsTableViewReuse];
        cell.settingLabel.text = _settingsArray[indexPath.row];
        return cell;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
